package com.t360.numberencoding;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Dictionary. Built as a hash map [normalized entry] -> [actual entry]
 * @author fmanganiello
 *
 */
public class Dictionary  {
	private Map<String, String> dictionary;
	
	public Dictionary(final List<String> list) {
		this.dictionary = new HashMap<String, String>();
		
		for (String word : list) {
			this.dictionary.put(normalizeString(word), word);
		}
	}
	
	/**
	 * Normalize a dictionary entry, removing the " characters from it
	 * @param string
	 * @return
	 */
	private static String normalizeString(final String string) {
		return string.toLowerCase().replaceAll("\"", "");
	}
	
	/**
	 * Get a dictionary entry
	 * @param key
	 * @return
	 */
	public String get(final String key) {
		return dictionary.get(key);
	}
}
